﻿using System;
using SimpleServiceBus.Endpoint.Management.Monitoring;
using SimpleServiceBus.Messages.Management.Monitoring;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;

namespace SimpleServiceBus.Tests.Endpoint.Management
{
    [TestFixture]
    public class PerfCounterProbeTestFixture
    {
        [Test]
        public void PerfCounterProbeTest()
        {
            var probe = new PerfCounterProbe
                            {
                                Name = "PercentProcessorTime",
                                UnitOfMeasurement = "Percent",
                                Category = "Memory",
                                Counter = "Available MBytes",
                                Instance = ""
                            };

            EndpointMeasurement measurement = probe.TakeMeasurement(null);

            Assert.IsFalse(String.IsNullOrEmpty(measurement.Value));

            double dbl = -1.0;
            dbl = Double.Parse(measurement.Value);
            Assert.That(dbl, Is.GreaterThan(0.0d));
            Assert.AreEqual("PercentProcessorTime", measurement.Name);
            Assert.AreEqual("Percent", measurement.UnitOfMeasurement);
        }
    }
}